﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x0200039B RID: 923
public class ColorPaletteCell : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IEventSystemHandler
{
	// Token: 0x060016D9 RID: 5849 RVA: 0x000997C4 File Offset: 0x000979C4
	private void Start()
	{
		this.frame.enabled = false;
	}

	// Token: 0x060016DA RID: 5850 RVA: 0x000997D4 File Offset: 0x000979D4
	public void Setup(int id, Color color, Action<int> onSave, Action<int> onLoad)
	{
		this.id = id;
		this.SetColor(color);
		this.onSave = onSave;
		this.onLoad = onLoad;
	}

	// Token: 0x060016DB RID: 5851 RVA: 0x000997F4 File Offset: 0x000979F4
	private void Update()
	{
	}

	// Token: 0x060016DC RID: 5852 RVA: 0x000997F8 File Offset: 0x000979F8
	private void OnDisable()
	{
		this.frame.enabled = false;
	}

	// Token: 0x060016DD RID: 5853 RVA: 0x00099808 File Offset: 0x00097A08
	public void OnPointerEnter(PointerEventData data)
	{
		this.frame.enabled = true;
	}

	// Token: 0x060016DE RID: 5854 RVA: 0x00099818 File Offset: 0x00097A18
	public void OnPointerExit(PointerEventData data)
	{
		this.frame.enabled = false;
	}

	// Token: 0x060016DF RID: 5855 RVA: 0x00099828 File Offset: 0x00097A28
	public void OnPointerDown(PointerEventData data)
	{
		if (data.button == PointerEventData.InputButton.Left)
		{
			if (this.onSave != null)
			{
				this.onLoad(this.id);
			}
		}
		else if (data.button == PointerEventData.InputButton.Right && this.onSave != null)
		{
			this.onSave(this.id);
		}
	}

	// Token: 0x060016E0 RID: 5856 RVA: 0x0009988C File Offset: 0x00097A8C
	public void SetColor(Color color)
	{
		Color color2 = color;
		color2.a = 1f;
		this.colorImage.color = color;
		this.opaqueImage.color = color2;
		this.frame.color = ColorPicker.InverseColor(color2);
	}

	// Token: 0x04001A9A RID: 6810
	[SerializeField]
	private Image colorImage;

	// Token: 0x04001A9B RID: 6811
	[SerializeField]
	private Image opaqueImage;

	// Token: 0x04001A9C RID: 6812
	[SerializeField]
	private Image frame;

	// Token: 0x04001A9D RID: 6813
	private int id;

	// Token: 0x04001A9E RID: 6814
	private Action<int> onSave;

	// Token: 0x04001A9F RID: 6815
	private Action<int> onLoad;
}
